package com.maszy.db;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigurableConstants {
	protected static Log logger = LogFactory.getLog(ConfigurableConstants.class);

	protected static Properties p = new Properties();

	protected static void init(String propertyFileName) {
		InputStream in = null;
		try {
			in = ConfigurableConstants.class.getClassLoader().getResourceAsStream(propertyFileName);
			if (in != null) {
				p.load(in);
			}
		} catch (IOException e) {
			logger.error("���� [" + propertyFileName + "] ���ó�������:" + e.getMessage());
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					in = null;
					logger.error("�ͷ� [" + propertyFileName + "] ��Դ���:" + e.getMessage());
				}
			}
		}
	}

	public static String getProperty(String key, String defaultValue) {
		return p.getProperty(key, defaultValue);
	}

	public static String getProperty(String key) {
		return p.getProperty(key);
	}
}
